from sqlmodel import Field, SQLModel, Index
from datetime import datetime

class MonitorBuy(SQLModel, table=True):
    """用户购买监控表"""
    __tablename__ = "t_monitor_buy"

    # 索引定义
    __table_args__ = (
        Index("idx_uid", "uid", info="用户ID索引"),
        Index("idx_archiveId", "archiveId", info="用户藏品ID索引"),
    )

    id: int = Field(default=None, primary_key=True, index=True, description="主键ID")
    uid: int = Field(default=0, index=True, description="用户ID")
    nickname: str = Field(default="", max_length=128, description="用户昵称")
    archiveId: int = Field(default=0, index=True, description="用户藏品ID")
    archiveName: str = Field(default="", max_length=128, description="用户藏品名称")
    archiveImg: str = Field(default="", max_length=255, description="用户藏品图片URL")
    platformId: int = Field(default=0, description="藏品发行平台ID")
    buyPrice: int = Field(default=0, description="买入价格")
    maxBuyNum: int = Field(default=0, description="购买数量")
    boughtNum: int = Field(default=0, description="已购买数量")
    status: int = Field(default=0, description="状态：0-监控中 1-已完成 2-已暂停 3-已取消")
    days: int = Field(default=0, description="监控天数")
    expireAt: datetime = Field(default_factory=datetime.now, description="过期时间戳")
    pauseRemark: str = Field(default="", max_length=255, description="暂停备注")
    createdAt: datetime = Field(default_factory=datetime.now, description="创建时间")
    updatedAt: datetime = Field(default_factory=datetime.now, description="更新时间")
